package cn.zn.modules.pz.his.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.mongodb.morphia.annotations.Entity;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@Entity
@Document(collection = "pz_traffic")
public class PzTraffic {
    @Field("ap")
    private Integer ap;
    @Field("main_id")
    private String mainId;
    @Field("traffic_id")
    private String trafficId;
    @Field("create_time")
    private Date createTime;
    @Field("create_user_id")
    private String createUserId;
    @Field("is_active")
    private Boolean isActive;
    @Field("remark")
    private String remark;
    @Field("sort_num")
    private Integer sortNum;
    @Field("update_time")
    private Date updateTime;
    @Field("update_user_id")
    private String updateUserId;
    @Field("version")
    private Integer version;
    @Field("end_place")
    private String endPlace;
    @Field("end_time")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;
    @Field("expense_unit")
    private String expenseUnit;
    @Field("number")
    private Integer number;
    @Field("price")
    private String price;
    @Field("start_place")
    private String startPlace;
    @Field("start_time")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startTime;
    @Field("total_price")
    private Double totalPrice;
    @Field("traffic")
    private String traffic;

    public String toString() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(sdf.format(this.startTime))
                .append(" 至 ").append(sdf.format(this.endTime))
                .append(" ").append(this.startPlace).append("-").append(this.endPlace).append(" 乘").append(this.traffic);
        return stringBuffer.toString();
    }
}
